package org.jianghu.activity.splash.presenter;

import android.content.Context;

import org.jianghu.activity.splash.view.WelcomeView;
import org.jianghu.utils.JH;
import org.jianghu.utils.SharedPreferencesUtil;

/**
 * Created by Administrator on 2016/12/19.
 */

public class WelcomePresenterCompl implements WelcomePresenter{

    private WelcomeView welcomeView;
    private Context context;

   public WelcomePresenterCompl(WelcomeView welcomeView,Context context){
        this.welcomeView = welcomeView;
        this.context = context;
   }

    //判断是不是第一次执行程序
    @Override
    public void isFirstRun() {
        boolean isFirstRun = (boolean) SharedPreferencesUtil.getData(context, JH.SHARED_IS_FIRST_RUN_KEY,false);
        if(isFirstRun){
            welcomeView.isFirstRun(true);
        }else{
            welcomeView.isFirstRun(false);
        }
    }

    @Override
    public void saveFirstRun() {
        SharedPreferencesUtil.saveData(context, JH.SHARED_IS_FIRST_RUN_KEY,true);
    }

}
